home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / ThreadStuff / AYSThreadGlue.cp next >
Encoding:
Text File  |  1995-07-28  |  1.6 KB  |  54 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        AYSThreadGlue.cp
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. //
  15. //    By defining this macro differently here, we get different results from our 
  16. //    header file AYSGlue.h.  This macro causes the MakePBFunctionSleepable macro
  17. //    make 'glue' functions, so that
  18. //
  19. //        MakePBFunctionSleepable(FSOpen,ParamBlockRec)
  20. //    
  21. //    creates a new function
  22. //
  23. //        OSErr FSOpenGlue(ParamBlockRec* pb, Boolean async) {
  24. //            return FSOpen(pb, async);
  25. //        };
  26. //
  27. //    This glue function is useful with the Threads package, because with threads we
  28. //    want to be able to call async functions from a thread, and have that thread
  29. //    automatically put to sleep until the call completes.  To do this, the 
  30. //    definition of the macro MakePBFunctionSleepable in the AYSGlue.h file does
  31. //    the following:
  32. //
  33. //        MakePBFunctionSleepable(FSOpen, ParamBlockRec)
  34. //
  35. //    creates a new function
  36. //
  37. //        OSErr FSOpenSleep(ParamBlockRec* pb) {
  38. //            return TFSDispatchAsync((FNPBB) FSOpenFlue, (ParmBlkPtr) pb);
  39. //        };
  40. //
  41. //    Notice that this function includes the address of the glue function created by
  42. //    the macro when the AYSGlue.cp file is compiled.  And, by calling FSOpenSleep(),
  43. //    the calling thread will be put to sleep until the call completes.
  44. //
  45. #define MakePBFunctionSleepable(function,ParamBlockType) \
  46.     pascal OSErr name2(function,Glue)(ParamBlockType *pb, Boolean asyncFlag) { \
  47.         return function(pb, asyncFlag); \
  48.     };
  49.  
  50. #pragma segment Main
  51.  
  52. #include "AYSThreadGlue.h"
  53.  
  54.